<template>
	<view>
		<view class="uni-list">
			<view class="uni-list-cell li-height" hover-class="uni-list-cell-hover" v-for="(value,key) in list" :key="key">
				<view class="uni-media-list uni-pull-right file-list">
					<view class="add-time file-time">
						{{value.createDate}}
					</view>
					<view class="uni-media-list-body file-name">
						<view class="uni-media-list-text-bottom" @click="fujian(key)">
							{{value.fileName}}
						</view>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>
<script>
	import global_ from '../../../components/tool/productGlobal'
	export default {
		data() {
			return {
				title: 'media-list',
				url: global_.api.PRODUCT_FUJIAN,
				showImg: false,
				list: [],
				projId:uni.getStorageSync('projId'),
				fileUrl:''
			}
		},
		onLoad() {
			setTimeout(() => {
				this.showImg = true;
			}, 400)
		},
		methods:{
			getData(){
				console.log('我是附件的请求内容');
				console.log('-------------'+this.projId);   // 前一个页面传的id值
				uni.request({
					method:'get',
					url: this.url+'?projId='+this.projId,
					header: {
						'content-type': 'application/x-www-form-urlencoded'
					},
					data: {
						projId: this.projId
					},
					dataType: 'json',
					success: (res) => {
						console.log(res);
						console.log('拿到的数据---------------'+res.data.code);
						this.list = res.data.data;
						console.log('------'+this.list);
					},
					fail: (err) => {
						console.log('取附件数据报错');
					},
					complete: () => {}
				})
			},
			fujian(key){
				console.log('拿到的key'+key);
				console.log('key的url'+this.list[key].fileUrl);
				uni.setStorageSync('fileUrl',this.list[key].fileUrl);  // 设置缓存的文件路径
				uni.navigateTo({
					url:'./fujianTxt',
					success: res => {},
					fail: () => {},
					complete: () => {}
				})
			}
		},
		onLoad(){
			this.getData();
		}
	}
</script>

<style scoped="scoped">
.title {
	/* padding: 10upx; */
}
	
.uni-media-list-body{
	height: auto!important;
	/* float: left; */
}
.uni-media-list-body a{
	display: block;
	height: auto;
	width: 150px;
	display: -webkit-box;
	-webkit-box-orient: vertical;
	-webkit-line-clamp: 2;
	overflow: hidden;
	white-space: pre-wrap;
}
.uni-ellipsis{
	white-space: pre-wrap;
}
.uni-media-list-text-bottom{
	line-height:normal;
}
a{
	color:#8f8f94;
	text-decoration: none;
}
.add-time{
	padding-left: 10px;
}
.uni-media-list{
	padding-top: 10px;
	padding-bottom: 10px;
	height: auto;
}
.file-list{
	display: flex;
}
.file-name{
	flex:7;
}
.file-name view{
	text-align:left;
}
.file-time{
	flex: 5;
}
</style>
